cmake_minimum_required(VERSION 3.19)
#将cpp版本限制为c++17这个很关键
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(YoloTargetDetect LANGUAGES CXX)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

find_package(Qt6 6.5 REQUIRED COMPONENTS Core Gui OpenGL OpenGLWidgets Widgets)

qt_standard_project_setup()

qt_add_executable(YoloTargetDetect
    WIN32 MACOSX_BUNDLE
    main.cpp



    mainform.h mainform.cpp mainform.ui
    commons.cpp commons.h inference.cpp inference.h
    modelloader.h modelloader.cpp
    resource/images.qrc
    threadsafequeue.h threadsafequeue.cpp
    detectthread.h detectthread.cpp
    videocapturedetectthread.h videocapturedetectthread.cpp
    cvmatdetectthread.h cvmatdetectthread.cpp
    README.md
    videofiledetectthread.cpp videofiledetectthread.h
)

# ##########  Config OpenCV  ##########
set(OpenCV_PATH d:/vcpkg/run/opencv/build)
include_directories(${OpenCV_PATH}/include)
link_directories(${OpenCV_PATH}/x64/vc16/lib)
file(GLOB OpenCV_LIBS ${OpenCV_PATH}/x64/vc16/lib/*4110d.lib)

target_link_libraries(YoloTargetDetect
    PRIVATE
        Qt::Core
        Qt6::Gui
        Qt6::OpenGL
        Qt6::OpenGLWidgets
        Qt6::Widgets
        ${OpenCV_LIBS}

)
# target_link_libraries 只允许一次
# target_link_libraries(${PROJECT_NAME}
#         ${OpenCV_LIBS}
# )

include(GNUInstallDirs)

install(TARGETS YoloTargetDetect
    BUNDLE  DESTINATION .
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

qt_generate_deploy_app_script(
    TARGET YoloTargetDetect
    OUTPUT_SCRIPT deploy_script
    NO_UNSUPPORTED_PLATFORM_ERROR
)
install(SCRIPT ${deploy_script})

